<?php

foreach ($this->data as $value) {
    $kdsatker = $value->get_nmsatker();
    $kdkppn = $value->get_attribute6();
}

foreach ($this->data2 as $value) {
    $tgl1 = $value->get_tgl1();
    $tgl2 = $value->get_tgl2();
}

$filename = "PMSPA".$kdkppn.$kdsatker.date('Ymd')."0".date('H'). ".xml";

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment;Filename=" . $filename);

echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
echo "<SP2Ds>\n";
if (isset($this->data)) {
    foreach ($this->data as $value) {
        echo "<SP2D>\n";
        echo "<no_batch></no_batch>\n";
        echo "<tanggal_sp2d>".trim($value->get_jumlah_sp2d())."</tanggal_sp2d>\n";
        echo "<no_sp2d>".trim($value->get_check_number())."</no_sp2d>\n";
        echo "<kode_satker>".trim($value->get_nmsatker())."</kode_satker>\n";
        echo "<operating_unit></operating_unit>\n";
        echo "<no_resume_tagihan></no_resume_tagihan>\n";
        echo "<no_spm>".trim($value->get_total_sp2d())."</no_spm>\n";
        echo "<tahun_anggaran>".trim($value->get_thang())."</tahun_anggaran>\n";
        echo "<tanggal_buat>".date('d-M-y')."</tanggal_buat>\n";
        echo "<payment_term></payment_term>\n";
        echo "<coa></coa>\n";
        echo "<lines></lines>\n";
        echo "<nilai_sp2d></nilaisp2d>\n";
        echo "<kdvalas></kdvalas>\n";
        echo "<nilai_kurs></nilai_kurs>\n";
        echo "<tgl_kurs></tgl_kurs>\n";
        echo "<nil_idr></nil_idr>\n";
        echo "<no_wa></no_wa>\n";
        echo "<tanggal_wa></tanggal_wa>\n";
        echo "<no_nod></no_nod>\n";
        echo "<tanggal_nod></tanggal_nod>\n";
        echo "<kurs_nod></kurs_nod>\n";
        echo "<tanggal_kurs_nod></tanggal_kurs_nod>\n";
        echo "<amount_nod></amount_nod>\n";
        echo "<end_of_line>ZZ</end_of_line>\n";
        echo "</SP2D>\n";
    }
}
echo "</SP2Ds>\n";
?>